<template>
  <div class="photoinfo-container">
    <h3 class="title">{{info.title}}</h3>
    <p class="subtitle">
      <span>{{info.add_time | dataFormat}}</span>
      <span>点击{{info.click}}次</span>
    </p>
    <hr />
    <img :src="item.src"  v-for="(item,index) in imagelist" :key="item.src" class="preview-img" height="100" @click="$preview.open(index,imagelist)">
    <div class="content" v-html="this.info.content"></div>
    <!-- 评论组件需要给它一个id -->
    <comment :id="this.id"></comment>
  </div>
</template>
<script>
import comment from "../subcomponents/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      info: {},
      imagelist: []
    };
  },
  methods: {
    getPhotoInfo() {
      this.$http.get("getimageInfo/" + this.id).then(result => {
        if (result.data.status == 0) {
          // console.log(result);
          this.info = result.data.message[0];
        }
      });
    },
    getThumbs() {
      this.$http.get("getthumimages/" + this.id).then(function(result) {
        if (result.data.status == 0) {
          console.log(result.data.message);
          result.data.message.forEach(item => {
            item.w = 600;
            item.h = 400;
          });
          this.imagelist = result.data.message;
        }
      });
    }
  },
  components: {
    comment
  },
  mounted() {
    console.log(this.id);

    this.getPhotoInfo();
    this.getThumbs();
  }
};
</script>
<style lang="scss">
.photoinfo-container {
  padding: 3px !important;
  .title {
    color: #26a2ff;
    font-size: 15px;
    text-align: center;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
  }
  img {
    margin:0 10.5px
  }
  .content {
    font-size: 13px;
    line-height: 23px;
  }
}
</style>